import java.util.Random;
import java.util.Scanner;

public class game {

    game(){
        Scanner scanner = new Scanner(System.in);
        char choice;
        do {
            Random random = new Random();
            int target = random.nextInt(1000) + 1;
            int count = 0;
            boolean guessed = false;
            while (count < 10) {
                System.out.print("输入你猜的数字(1 - 1000): ");
                int guess = scanner.nextInt();
                count++;
                if (guess == target) {
                    guessed = true;
                    System.out.println("太棒了，你猜对了！");
                    break;
                } else if (guess > target) {
                    System.out.println("太大了.再试一次.");
                } else {
                    System.out.println("太小了.再试一次.");
                }
            }
            if (!guessed) {
                System.out.println("对不起，你已经猜了10次，这个数字为 " + target);
            }
            System.out.print("你想再玩一把吗? (y/n): ");
            choice = scanner.next().charAt(0);
        } while (choice == 'y' || choice == 'Y');
    }
}
